# Q1. 输入单词需要的最少按键次数 I
from typing import *


class Solution:
    def minimumPushes(self, word: str) -> int:
        cnt = Counter(word)
        l = sorted(cnt.items(), key=lambda a: a[1], reverse=True)
        key = 0
        ans = 0
        for k, v in l:
            ans += v * (key // 8 + 1)
            key += 1
        return ans
